#include <bits/stdc++.h>

using i64 = long long;

constexpr int N = 1e5 + 5;

int n, m, q, B, sumS, sumT, timer, pos[N], dep[N], dfn[N], siz[N], son[N], top[N], fa[N], a[N], b[N];
std::string s[N], t[N];
std::vector<int> p[N];
std::map<int, std::bitset<N>> H;

struct ACAM {
	static constexpr int N = 1e5 + 5, S = 26;
	int tot, fail[N], trans[S][N];
	std::vector<int> G[N];
	void init() { tot = 0; }
	int newNode() {
		++tot, fail[tot] = 0;
		for (int i = 0; i < S; i++) trans[i][tot] = 0;
		return tot;
	}
	int insert(std::string s) {
		int u = 0;
		for (auto ch : s) {
			if (!trans[ch - 'a'][u]) trans[ch - 'a'][u] = newNode();
			u = trans[ch - 'a'][u];
		}
		return u;
	} 
	void dfs1(int u) {
		siz[u] = 1, son[u] = -1;
		for (auto v : G[u]) {
			fa[v] = u, dep[v] = dep[u] + 1;
			dfs1(v), siz[u] += siz[v];
			if (son[u] == -1 || siz[v] > siz[son[u]]) son[u] = v;
		}
	}
	void dfs2(int u, int tp) {
		dfn[u] = ++timer, top[u] = tp;
		if (~son[u]) dfs2(son[u], tp);
		for (auto v : G[u]) if (v != son[u]) dfs2(v, v);
	}
	int LCA(int u, int v) {
		while (top[u] != top[v]) {
			if (dep[top[u]] < dep[top[v]]) std::swap(u, v);
			u = fa[top[u]];
		}
		return dep[u] < dep[v] ? u : v;
	}
	void build() {
		std::queue<int> q;
		for (int i = 0; i < S; i++) if (trans[i][0]) q.push(trans[i][0]);
		while (!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < S; i++) {
				if (trans[i][u]) fail[trans[i][u]] = trans[i][fail[u]], q.push(trans[i][u]);
				else trans[i][u] = trans[i][fail[u]];
			}
		}
		for (int i = 1; i <= tot; i++) G[fail[i]].push_back(i);
		dfs1(0), dfs2(0, 0);
	}
} M;

bool cmp(int lhs, int rhs) { return dfn[lhs] < dfn[rhs]; }

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	std::cin >> n >> m >> q, M.init();
	for (int i = 1; i <= n; i++) std::cin >> s[i], sumS += s[i].length(), pos[i] = M.insert(s[i]);
	for (int i = 1; i <= m; i++) std::cin >> t[i], sumT += t[i].length();
	M.build(), B = sqrt((1ll * n * sumT) / (1ll * q * std::__lg(sumT))) + 1;
	for (int i = 1; i <= m; i++) if ((int)t[i].length() > B) {
		int u = 0;
		for (auto ch : t[i]) u = M.trans[ch - 'a'][u], a[dfn[u]]++;
		for (int j = 1; j <= M.tot + 1; j++) a[j] += a[j - 1];
		for (int j = 1; j <= n; j++) if (a[dfn[pos[j]] + siz[pos[j]] - 1] - a[dfn[pos[j]] - 1]) H[i][j] = 1;
		for (int j = 1; j <= M.tot + 1; j++) a[j] = 0;
	}
	for (int i = 1; i <= n; i++) a[dfn[pos[i]]]++, a[dfn[pos[i]] + siz[pos[i]]]--;
	for (int i = 1; i <= M.tot + 1; i++) a[i] += a[i - 1];
	for (int i = 1; i <= m; i++) {
		int u = 0;
		for (auto ch : t[i]) u = M.trans[ch - 'a'][u], p[i].push_back(u);
		std::sort(p[i].begin(), p[i].end(), cmp);
		for (auto v : p[i]) b[i] += a[dfn[v]];
		for (int j = 1; j < (int)p[i].size(); j++) b[i] -= a[dfn[M.LCA(p[i][j - 1], p[i][j])]];
	}
	while (q--) {
		int x, y; std::cin >> x >> y;
		if (t[x].length() > t[y].length()) std::swap(x, y);
		if ((int)t[x].length() <= B) {
			std::vector<int> R(p[x].size()); int U = b[y];
			for (int i = 0; i < (int)p[x].size(); i++) {
				R[i] = std::lower_bound(p[y].begin(), p[y].end(), p[x][i], cmp) - p[y].begin();
				U += a[dfn[p[x][i]]];
			}
			for (int l = 0, r = 0; l < (int)p[x].size(); l = r + 1) {
				while (r + 1 < (int)p[x].size() && R[r + 1] == R[l]) r++;
				for (int i = l + 1; i <= r; i++) U -= a[dfn[M.LCA(p[x][i - 1], p[x][i])]];
				if (R[l] == 0) {
					U -= a[dfn[M.LCA(p[x][r], p[y].front())]];
				}
				else if (R[l] == (int)p[y].size()) {
					U -= a[dfn[M.LCA(p[x][l], p[y].back())]];
				}
				else {
					U += a[dfn[M.LCA(p[y][R[l] - 1], p[y][R[l]])]];
					U -= a[dfn[M.LCA(p[y][R[l] - 1], p[x][l])]] + a[dfn[M.LCA(p[x][r], p[y][R[l]])]];
				}
			}
			std::cout << b[x] + b[y] - U << "\n";
		}
		else std::cout << (H[x] & H[y]).count() << "\n";
	}
	return 0;
}
